<?php

namespace App\Http\Controllers;

use App\Http\Controllers\BaseController;
use Illuminate\Http\Request;
use App\Traits\BaseHttp;
use App\Services\UploadService;

class UploadController extends BaseController
{
    /**
     * 上传图片，公共
     * @param  Request  $request
     * @return JsonResponse
     */
    public function uploadPic(Request $request)
    {
        $file = $request->file('file');
        $res = @UploadService::uploadPic($file);
        if ($res['errcode']) {
            return $this->error(401, $res['errmsg']);
        }

        return $this->success($res['data']);
    }
}